package com.wj.taobaoke.daohang;

import com.wj.taobaoke.GenerateBlogFile;
import com.wj.taobaoke.ReadTemplate;
import com.wj.taobaoke.naifen.NaiFenGuanJianZi;

public class GenerateDaoHangBlogFile {
	
	public static void main(String[] args) {
		
		String templateFileName = "daoHangTemplate.html";
		ReadTemplate readTemplate = new ReadTemplate();
		readTemplate.readTemplateList(templateFileName);

		GenerateBlogFile generateBlogFile = new GenerateBlogFile(readTemplate);
		
		generateBlogFile.generatgeBaiduNewsList(DaoHangGuanJianZi.ZuiXinQiCheDaoHang().init(readTemplate.getProjectPath()));
		generateBlogFile.generatgeBaiduNewsList(DaoHangGuanJianZi.QiCheDaoHangJiaGe().init(readTemplate.getProjectPath()));
		generateBlogFile.generatgeBaiduNewsList(DaoHangGuanJianZi.QiCheDaoHangPinPaiPaiMing().init(readTemplate.getProjectPath()));
		generateBlogFile.generatgeBaiduNewsList(DaoHangGuanJianZi.DianZiGuoDaoHang().init(readTemplate.getProjectPath()));
		generateBlogFile.generatgeBaiduNewsList(DaoHangGuanJianZi.GPSDaoHang().init(readTemplate.getProjectPath()));
		generateBlogFile.generatgeBaiduNewsList(DaoHangGuanJianZi.DaoHangUp().init(readTemplate.getProjectPath()));
		GenerateBlogFile.executor.shutdown();
		try {
			while(GenerateBlogFile.executor.getPoolSize() != 0){
				Thread.sleep(GenerateBlogFile.executor.getPoolSize() * 1000);
				System.out.println("size=="+GenerateBlogFile.executor.getPoolSize());
				if(GenerateBlogFile.allItemList.size() > 0){
					System.out.println(GenerateBlogFile.allItemList.get(0).index+"_"+GenerateBlogFile.allItemList.get(0).contentUrl);
				}
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println("ok");
	}
}
